<?xml version="1.0" encoding="utf-8" ?>
<xs:schema id="Mapping" targetNamespace="http://euss.evaluant.com/schemas/MappingSchema.xsd"
	xmlns:mstns="http://euss.evaluant.com/schemas/MappingSchema.xsd" xmlns="http://euss.evaluant.com/schemas/MappingSchema.xsd"
	xmlns:xs="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="qualified">
	
	<xs:simpleType name="DbType">
    <xs:restriction base="xs:string">
      <xs:enumeration value="AnsiString" />
      <xs:enumeration value="AnsiStringFixedLength" />
      <xs:enumeration value="Binary" />
      <xs:enumeration value="Boolean" />
      <xs:enumeration value="Byte" />
      <xs:enumeration value="Currency" />
      <xs:enumeration value="Date" />
      <xs:enumeration value="DateTime" />
      <xs:enumeration value="Decimal" />
      <xs:enumeration value="Double" />
      <xs:enumeration value="Int16" />
      <xs:enumeration value="Int32" />
      <xs:enumeration value="Int64" />
      <xs:enumeration value="Guid" />
      <xs:enumeration value="Object" />
      <xs:enumeration value="SByte" />
      <xs:enumeration value="Single" />
      <xs:enumeration value="String" />
      <xs:enumeration value="StringFixedLength" />
      <xs:enumeration value="UInt16" />
      <xs:enumeration value="UInt32" />
      <xs:enumeration value="UInt64" />
    </xs:restriction>
  </xs:simpleType>

	<xs:element name="Mapping">
		<xs:complexType>
			<xs:choice minOccurs="0" maxOccurs="unbounded">
				<xs:element name="Entity">
					<xs:complexType>
						<xs:sequence>
							<xs:element name="Id" minOccurs="0" maxOccurs="unbounded">
								<xs:complexType>
									<xs:sequence>
										<xs:element name="Generator" minOccurs="0" maxOccurs="unbounded">
											<xs:complexType>
												<xs:sequence>
													<xs:element name="Property" nillable="true" minOccurs="0" maxOccurs="unbounded">
														<xs:complexType>
															<xs:simpleContent>
																<xs:extension base="xs:string">
																	<xs:attribute name="name" type="xs:string" />
																</xs:extension>
															</xs:simpleContent>
														</xs:complexType>
													</xs:element>
												</xs:sequence>
												<xs:attribute name="name" type="xs:string" />
											</xs:complexType>
										</xs:element>
									</xs:sequence>
									<xs:attribute name="field" type="xs:string" />
								</xs:complexType>
							</xs:element>
							<xs:element name="Attribute" minOccurs="0" maxOccurs="unbounded">
								<xs:complexType>
									<xs:attribute name="name"  type="xs:string" />
									<xs:attribute name="table" type="xs:string" />
									<xs:attribute name="field" type="xs:string" />
									<xs:attribute name="type" type="xs:string" />
									<xs:attribute name="db-type" type="DbType" />
									<xs:attribute name="size" type="xs:string" />
									<xs:attribute name="parentField" type="xs:string" />
									<xs:attribute name="discriminator" type="xs:string" />
									<xs:attribute name="discriminator-value" type="xs:string" />
									<xs:attribute name="scale" type="xs:string" />
									<xs:attribute name="precision" type="xs:string" />
									<xs:attribute name="default-value" type="xs:string" />
									<xs:attribute name="not-null">
										<xs:simpleType>
											<xs:restriction base="xs:string">
												<xs:enumeration value="true" />
												<xs:enumeration value="false" />
											</xs:restriction>
										</xs:simpleType>
									</xs:attribute>
								</xs:complexType>
							</xs:element>
							<xs:element name="Reference" minOccurs="0" maxOccurs="unbounded">
								<xs:complexType>
									<xs:sequence>
										<xs:element name="Rule" minOccurs="0" maxOccurs="unbounded">
											<xs:complexType>
												<xs:attribute name="parentField" type="xs:string" />
												<xs:attribute name="childTable" type="xs:string" />
												<xs:attribute name="childField" type="xs:string" />
											</xs:complexType>
										</xs:element>
									</xs:sequence>
									<xs:attribute name="name" type="xs:string" />
									<xs:attribute name="entityChild" type="xs:string" />
                  <xs:attribute name="discriminator-field"  type="xs:string" />
                  <xs:attribute name="discriminator-value" type="xs:string" />
								</xs:complexType>
							</xs:element>
						</xs:sequence>
						<xs:attribute name="type" type="xs:string" />
						<xs:attribute name="table" type="xs:string" />
						<xs:attribute name="discriminator-field"  type="xs:string" />
						<xs:attribute name="discriminator-value" type="xs:string" />
						<xs:attribute name="copyNode" type="xs:string" />
					</xs:complexType>
				</xs:element>
			</xs:choice>
		</xs:complexType>
	</xs:element>
</xs:schema>